local jigong = fk.CreateSkill{
  name = "lingling__jigong",
}

Fk:loadTranslationTable{
  ["lingling__jigong"] = "急攻",
  [":lingling__jigong"] = "出牌阶段限一次，你可以摸一张牌，令你本回合手牌上限减至1，依次视为对同一个目标使用【火攻】、【穷寇勿迫】，若均未造成伤害，你对你和其各造成1点伤害。",

  ["#lingling__jigong"] = "急攻：重铸两张牌，依次对同一名角色使用【火攻】、【穷寇勿迫】",
  ["#lingling__jigong-use"] = "急攻：请将一张牌当【穷寇勿迫】对 %dest 使用",
}

jigong:addEffect("viewas", {
  anim_type = "offensive",
  mute_card = false,
  prompt = "#lingling__jigong",
  handly_pile = true,
  card_filter = Util.FalseFunc,
  view_as = function(self, player, cards)
    if #cards ~= 0 then return end
    local card = Fk:cloneCard("fire_attack")
    card.skillName = jigong.name
    --card:addFakeSubcards(cards)
    return card
  end,
  before_use = function (self, player, use)
    use.extra_data = {}
    use.extra_data.lingling__jigong = use.tos[1]
    --player.room:recastCard(use.card.fake_subcards, player, jigong.name)
    player.room:setPlayerMark(player, jigong.name.."-turn",1)
    player:drawCards(1, jigong.name)
  end,
  after_use = function (self, player, use)
    local room = player.room
    local to = use.extra_data.lingling__jigong
    if player.dead or to.dead or not player:canUseTo(Fk:cloneCard("ling__stop_chasing"), to) then return end
    --[[local use2 = room:askToUseVirtualCard(player, {
      name = "ling__stop_chasing",
      skill_name = jigong.name,
      prompt = "#lingling__jigong-use::"..to.id,
      cancelable = false,
      extra_data = {
        exclusive_targets = { to.id },
      },
      card_filter = {
        n = 0,
      },
    })]]--
    local use2 = room:useVirtualCard("ling__stop_chasing", nil, player, {to}, jigong.name)
    if player.dead or use2 == nil then return end
    if not use.damageDealt and not use2.damageDealt then
      room:damage{
        from = player,
        to = player,
        damage = 1,
        skillName = jigong.name,
      }
      if not to.dead then
        room:damage{
          from = player,
          to = to,
          damage = 1,
          skillName = jigong.name,
        }
      end
    end
  end,
  enabled_at_play = function (self, player)
    return player:usedSkillTimes(jigong.name, Player.HistoryPhase) == 0 and
      #player:getCardIds("he") > 1
  end,
})

jigong:addEffect("maxcards",{
  fixed_func = function(self, player)
    if player:getMark(jigong.name.."-turn") ~= 0 then
      return 1
    end
  end
})

jigong:addAI(nil, "vs_skill")

return jigong
